Skip to content

Fix missing path parameters when also adding headers#216

Merged
alufers merged 1 commit into
alufers:masterfrom
matgoebl:fix-missing-path-parameters-with-headers
May 25, 2026
Merged

Fix missing path parameters when also adding headers#216
alufers merged 1 commit into
alufers:masterfrom
matgoebl:fix-missing-path-parameters-with-headers

Conversation

@matgoebl

Copy link
Copy Markdown
Contributor

mitmproxy2swagger adds path parameters like /{id} correctly as

      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string

When using mitmproxy2swagger --headers the headers are added, but the parameters will be missing:

      parameters:
      - name: content-type
        in: header
        required: false
        schema:
          type: string

The correct result should be

      parameters:
      - name: content-type
        in: header
        required: false
        schema:
          type: string
      - name: id
        in: path
        required: true
        schema:
          type: string

The reason for this bug is that if args.headers is used, the key parameters in swagger is already set and the later set_key_if_not_exists for params does not extend the key parameters.
One (least invasive) fix is to merge both arrays.

@alufers alufers merged commit d3f7bf9 into alufers:master May 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants